<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			body{ text-align:center} 
		</style>
	</head>
	<body>
		<select id="choose">
			<option value="">请选择大小</option>
			<option value="b">大</option>
			<option value="a">小</option>
		</select>
		<br>
			<img src="img/1.jpg" id="img_id" style="width: 150px;height: 150px;">
		<br>
		<button type="button" onclick="begin(event);">开始</button>
		
		
		
	</body>
	<script type="text/javascript">
		function begin(event){
			var choose=document.getElementById('choose').value;
			if(choose==""){
				alert('请选择!');
				return;
			}
			var but = event.target;
			but.disabled='disabled';
			var count =0;
			var num=0;
			var result="";
			var interval=setInterval(function (){
				if (count==10) {
					result=num<=3 ?'a':'b';
					if (result==choose) {
						alert('选择正确')
					} else{
						alert('选择错误')
					}
					clearInterval(interval);
					but.innerText='重来';
					but.disabled="";
					return;
				}
				num=getNum();
				document.getElementById('img_id').src='img/'+num+'.jpg';
				count++;
			},100)
			
		}
		
		function getNum(){
			var num=0;
			while (true){
				//floor向下取整 取到9
				num=Math.floor(Math.random()*10);
				if(num>0 && num<7){
					break;
				}
			}
			return num;
		}
		
	</script>
</html>
